<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div {
            width: 100px;
            height: 30px;
            border: 1px solid pink;
        }
    </style>
</head>

<body>
    <div></div>
    <div></div>
    <div></div>
</body>
<script>
    let boxs = document.querySelectorAll('div');
    console.log(boxs);
    let sui = function () {
        let num = 0;
        for (let i = 0; i < boxs.length; i++) {
            if (boxs[i].style.backgroundColor === 'pink') {
                num++;
            }
        }
        if (num == 3) {
            setTimeout(function () {
                for (let a = 0; a < boxs.length; a++) {
                    boxs[a].style.backgroundColor = '';
                }
            }, 3000)
        }
    }
    for (let i = 0; i < boxs.length; i++) {
        boxs[i].addEventListener('click', function () {
            this.style.backgroundColor = 'pink';
            sui();
        })
    }


</script>

</html>